----------------------------------Spell Variables--------------------------------------
SPELL.m_iSpellID = 55312 -- Whatever value you want as long as it doesn't override any other spells' IDs.
SPELL.m_iRange = 1024
SPELL.m_sName = "Burst of Speed"
SPELL.m_sToolTip = [[You gain a burst of
					speed, increasing your
					movement speed by 50% for
					8 seconds.]]
SPELL.m_sIcon = "devin/blackbetty/spells/brawler/dropkick.png"
SPELL.m_iCoolDown = 6
SPELL.m_iManaCost = 50
SPELL.m_bRequiresTarget = true
SPELL.m_iSpellType = SPELLTYPE_MOBILITY
SPELL.m_bRecastWhileCasting = false

---------------------------------------------------------------------------------------

local range = 100
local weapondamage = 20

function SPELL:Cast( pl, target )
	print("Casted "..self.m_sName.."!")
	if(((target:GetPos()) - pl:GetPos()):Length() <= self.m_iRange)then
		pl:DoAnimationEvent(ACT_MP_RUN_PDA)
		pl:EmitSound("devin/blackbetty/weapons/CharacterRoarsOrcMale.wav", 100, 100+math.random(-10, 20))
		pl:EmitSound("devin/blackbetty/weapons/castsounds/FireCast.wav", 150, 100+math.random(-10,-35))
		ParticleEffectAttach( "fire_hands_instacast", PATTACH_POINT_FOLLOW, pl, pl:LookupAttachment("rightfoot"))
		ParticleEffectAttach( "fire_hands_instacast", PATTACH_POINT_FOLLOW, pl, pl:LookupAttachment("leftfoot"))
		local subtractedvectors = (pl:GetPos()) - target:GetPos()
		local subtractedvectorsnorm = (pl:GetPos()) - target:GetPos()
		subtractedvectorsnorm:Normalize()
		pl:SetPos(pl:GetPos() + Vector(0, 0, 16))
		pl:SetAngles((target:GetPos() - pl:GetPos()):Angle())
		pl:SetVelocity(-(subtractedvectorsnorm*(4*subtractedvectors:Length()+128)))
		target.Speed = true	
			target.SpeedMod = -1
			target.SpeedModDuration = 0.7
			target.SpeedType = "Charge"
		target:SetVelocity(target:GetVelocity()*-1) 
		timer.Simple(0.2, function()
			pl:SetVelocity(pl:GetVelocity()*-1) 
			if(((target:GetPos()) - pl:GetPos()):Length() <= 256)then
				local dmginfo = DamageInfo()
					dmginfo:SetDamage( 40 ) --50 damage
					dmginfo:SetDamageType( DMG_GENERIC ) --Bullet damage
					dmginfo:SetAttacker( pl ) --First player found gets credit
					dmginfo:SetDamageForce( Vector( 0, 0, 1000 ) ) --Launch upwards
				target:EmitSound("devin/blackbetty/weapons/pummel/pummel.wav", 160, 100+math.random(30,60))
				target:TakeDamageInfo( dmginfo ) 
				target:SetPos(target:GetPos()+Vector(0, 0, 24))
				target:SetVelocity(((pl:GetPos()+Vector(0, 0, 0)) - target:GetPos()+Vector(0, 0, 0))*-12)
				timer.Simple(0.3, function() 
					target:SetVelocity(target:GetVelocity()*-1) 
					target:EmitSound("devin/blackbetty/weapons/pummel/pummel.wav", 160, 100+math.random(50,100))
				end)
				ParticleEffect( "impact_firebig", target:GetPos() + Vector(0, 0, 46) + (target:GetAngles():Forward()*6), Angle(0,0,0), pl )
			end
				pl:SetNWBool("Casting", false) 
				pl:SetNWBool("Casted", false)
		end)
		else
		pl:SetNWBool("Casting", false) 
		pl:SetNWBool("Casted", false)
	end
end



